//
//  CMDBPublishResumeViewController.swift
//  CMDB
//
//  Created by 王磊 on 04/05/2017.
//  Copyright © 2017 CMDB. All rights reserved.
//

import UIKit

class CMDBPublishResumeViewController: CustomNormalContentViewController {
    
    private var scrollView: UIScrollView!
    
    private var labelCollectionView: TSLabelCollectionView = TSLabelCollectionView.getInstance()
    
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        
        navigationController?.navigationBarHidden = false
    }
    
    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        
        navigationController?.navigationBarHidden = true
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
        title = "生成简历"
        
        navigationController?.navigationBar.translucent = false
        
        scrollView = UIScrollView(frame: view.bounds)
        
        view.addSubview(scrollView)
        
        view.backgroundColor = UIColor.whiteColor()
        
        scrollView.addSubview(labelCollectionView)
        
        //        label.mDelegate = self
        
        let labelBean = TSLabelBean()
        
        labelBean.title = "全部"
        
        let labelBean1 = TSLabelBean()
        
        labelBean1.title = "导演"
        
        let labelBean2 = TSLabelBean()
        
        labelBean2.title = "监制"
        
        let labelBean3 = TSLabelBean()
        
        labelBean3.title = "灯光导演"
        
        let labelBean4 = TSLabelBean()
        
        labelBean4.title = "摄影导演"
        
        let labelBean5 = TSLabelBean()
        
        labelBean5.title = "灯光指导"
        
        let labelBean6 = TSLabelBean()
        
        labelBean6.title = "武术指导"
        
        let arr = [labelBean,labelBean1,labelBean2,labelBean3,labelBean4,labelBean5]
        
        let label_height = CGFloat(((arr.count) - 1) / 3 + 1) * (Label_Section_Item_Height + Label_Section_Item_Min_Space) + Label_Section_Header_Height
        
        labelCollectionView.frame = CGRectMake(0, 0, Label_Screen_Width,label_height )
        
        labelCollectionView.updateData(arr)
        
        scrollView.addSubview(collectionView)
        
        labelCollectionView.backgroundColor = UIColor.yellowColor()
        
        collectionView.frame = CGRectMake(0, label_height, Picture_Screen_Width, Picture_Screen_Width * 5 / 4)
        
        let arr1 = ["1","2","3","4","5","6"]
        
        collectionView.updateData(arr1)
        
        scrollView.contentSize = CGSizeMake(Label_Screen_Width, Picture_Screen_Width * 5 / 4 + label_height)
        
        labelCollectionView.addTarget(self, action: #selector(CMDBPublishResumeViewController.labelTest(_:)), forEvent: .LabelItem)
        
        collectionView.addTarget(self, action: #selector(CMDBPublishResumeViewController.pictureTest(_:)), forEvent: .PictureItem)
        
        collectionView.addTarget(self, action: #selector(CMDBPublishResumeViewController.pictureComment(_:)), forEvent: .Comment)
    }
    
    private var collectionView: TSPictureColletionView = TSPictureColletionView.getInstance()
    
}
extension CMDBPublishResumeViewController: TSPictureCollectionViewDelegate { }
// 轮播item点击
extension CMDBPublishResumeViewController {
    // MARK: 海报item 点击
    @objc func pictureTest(temp: TSArguInfo) {
        print("PictureItem")
        
    }
    // MARK: 海报item里的评论 点击
    
    @objc func pictureComment(temp: TSArguInfo) {
        
        print("Comment")
    }
    
    @objc private func btnClick() {
        
        
    }
    
    
    func onPictureCollectionItemSelected(data: AnyObject, indexPath: NSIndexPath) {
        
        
        
    }
}
extension CMDBPublishResumeViewController: TSLabelCollectionViewDelegate {}
// 标签item点击
extension CMDBPublishResumeViewController {
    
    @objc func labelTest(temp: TSArguInfo) {
        
        switch temp.itemType {
            
        case .LabelItem:
            
            labelCollectionView.selectItemAtIndexPath(temp.indexPath!)
            
            print("LabelItem")
            break
            
        default:
            break
        }
    }
    
    func onLabelCollectionItemSelected(data: AnyObject, indexPath: NSIndexPath) {
        
        
    }
}

